package cn.foreknow.dao.impl;

import cn.foreknow.dao.FoodDao;
import cn.foreknow.db.JdbcTemplate;
import cn.foreknow.model.Food;
import cn.foreknow.db.DBManager;

import java.sql.Connection;
import java.util.List;

public class FoodDaoImpl implements FoodDao {

    @Override
    public boolean save(Food food) throws Exception {
        String sql = "insert into food(foodName,foodExplain,foodPrice,businessId) " +
                "values(?,?,?,?)";
        DBManager db = DBManager.getInstance();
        Connection conn = db.getConnection();
        JdbcTemplate jt = JdbcTemplate.getInstance();
        jt.setConnection(conn);
        int i = jt.update(sql, food.getFoodName(), food.getFoodExplain(), food.getFoodPrice(), food.getBusinessId());
        return i==1;
    }

    @Override
    public boolean delete(int foodId) throws Exception {
        return false;
    }

    @Override
    public Food update(int foodId) throws Exception {
        return null;
    }

    @Override
    public List<Object> getQueryAll(Food food) throws Exception {
        return null;
    }

    @Override
    public Food getQueryById(Food food) throws Exception {
        return null;
    }
}
